﻿@{
    ViewBag.Title = "内容修改";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
<style>
    .margin-left1
    {
    	
        margin-left:00px;
     }
     .margin-left2
    {
        margin-left:30px;
     }
      .margin-left3
    {
        margin-left:60px;
     }
</style>

@model UcAsp.Net.Model.Subjects
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
                    <span class="icon"><i class="icon-align-justify"></i></span>
                    <h5>
                        基本设置</h5>
                </div>
                <div class="widget-content nopadding">
                    <form action="#" method="post" class="form-horizontal">
                    <input id="SubjectID" name="SubjectID" type="hidden" value="@Model.SubjectId" />
                    <input id="SubjectID" name="CId" type="hidden" value="@ViewData["CId"]" />
                    
                    <div class="control-group">
                        <label class="control-label">
                            栏目名称</label>
                        <div class="controls">
                            <input  class="text-input small-input" type="text" name="SubjectName"  value="@Model.SubjectName" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            分类选择</label>
                        <div class="controls">
                            <select multiple="multiple" name="Categories">
                            @{int i=0;}
                                @foreach (UcAsp.Net.Model.Select c in (List<UcAsp.Net.Model.Select>)ViewData["Categories"])
                                {
                                   // if (c.Parent == 0)
                                   // {
                                       
                                      //  <optgroup label="@c.Name"/>
                                        
                                   // }
                                    //else
                                   // {
                                     <option class="margin-left@{@c.Depth}"  value="@c.Value" @if (Model.CategoryName.IndexOf(c.Name) > -1)
                                                                                                           { <text>selected</text> }>@c.Name</option>
                                   // }
                                    i++;
                                }
                               
                                 
                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            栏目图片</label>
                        <div class="controls">
                            <input id="FileSubjectImg" name="FileSubjectImg" type="file"   />
                            <input id="SubjectImg" name="SubjectImg" type="hidden" value="@Model.SubjectImg" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            关键词</label>
                        <div class="controls">
                            <input class="text-input small-input" type="text" name="Keywords"  value="@Model.Keywords" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            显示数量</label>
                        <div class="controls">
                            <input class="text-input small-input" type="text" name="MaxNum"  value="@Model.MaxNum" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            显示方式</label>
                        <div class="controls">
                            <label>
                                <input name="WhoView" type="radio" value="1" @if (Model.WhoView == "1")
                                                                             {<text>checked</text>} />
                                最新查看</label>
                            <label>
                                <input name="WhoView" type="radio" value="2" @if (Model.WhoView == "2")
                                                                             {<text>checked</text>} />
                                最新加入</label>
                            <label>
                                <input name="WhoView" type="radio" value="3" @if (Model.WhoView == "3")
                                                                             {<text>checked</text>} />
                                推荐主题</label>
                            <label>
                                <input name="WhoView" type="radio" value="4" @if (Model.WhoView == "4")
                                                                             {<text>checked</text>}/>
                                热门点击</label>
                                <label>
                                <input name="WhoView" type="radio" value="5" @if (Model.WhoView == "5")
                                                                             {<text>checked</text>}/>
                                图片类</label>
                                <label>
                                <input name="WhoView" type="radio" value="6" @if (Model.WhoView == "6")
                                                                             {<text>checked</text>}/>
                                推荐图片</label>
                        </div>
                    </div>
                    <div class="control-group">
                        <div class="controls">
                            <div class="btn save">
                                保存</div>
                        </div>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $(".save").click(function () {
            UploadFile();
        })

    })
    function UploadFile() {
        $.upload({
            url: '/UploadFile.ashx',
            fileName:"FileSubjectImg",
            dataType: 'xml',
            onSend: function () {
                return true;
            },
            //上传之后回调
            onComplate: function (data) {
                if (data != null) {
                    $("input[name='SubjectImg']").attr("value", data);
                }
                $.post("/admin/SaveSubject", { SubjectId: $("input[name='SubjectID']").val(), CId: $("input[name='CId']").val(), SubjectName: $("input[name='SubjectName']").val(), SubjectImg: $("input[name='SubjectImg']").val(), Categories: $("select[name='Categories']").val(), CategoryName: $("select[name='Categories']").find("option:selected").text(), Keywords: $("input[name='Keywords']").val(), MaxNum: $("input[name='MaxNum']").val(), WhoView: $('input:radio[name="WhoView"]:checked').val() @if(Request["Message"]!=null){<text>, Message: 'show'</text>}  }, function (dataResult) {
                    
                    window.location = "/Admin/SubjectManage?CId=" + $("input[name='CId']").val();
                })

            }
        });
    }
</script>
